package com.airticketbooking.mapper;

import com.airticketbooking.po.Ticket;
import com.airticketbooking.query.TicketPageQuery;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Mr.J
 * @version 1.0.0
 * @date 2024/10/21
 * @desc
 */
@Mapper
public interface TicketMapper {

	Page<Ticket> pageQuerylist(TicketPageQuery ticketPageQuery);


	void add(Ticket ticket);

	void update(Ticket ticket);

	@Select("SELECT * FROM airticketbooking.ticket WHERE ticket_id = #{id}")
	Ticket getTicketById(Integer id);

	void startOrstopTicket(Integer scheduleId, Integer status);

	@Select("SELECT ticket_id FROM airticketbooking.ticket " +
			"WHERE schedule_id = #{scheduleId} AND status in(0,1)" +
			" limit 1")
	Integer getByShcheduleIdList1(Integer scheduleId);


	@Select("SELECT ticket_id FROM airticketbooking.ticket WHERE schedule_id = #{scheduleId} limit 1")
	List<Integer> getByShcheduleIdListAll(Integer scheduleId);


	@Select("SELECT * FROM airticketbooking.ticket WHERE schedule_id = #{scheduleId}")
	List<Ticket> getTicketByScheduleId(Integer scheduleId);
}
